﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebApiClient.Attributes;
using WebApiClient;
using QQRobot.Services.Models.Response;
using QQRobot.Services.Models.Request;

namespace QQRobot.Services
{
    /// <summary>
    /// SiliconFlow平台下的AI对话<see cref="https://cloud.siliconflow.cn/"/>
    /// </summary>
    public class SiliconFlowAPI
    {
        public const string key = "sk-kwocbgqjoqjhplbzqxhkqtplmnreuzfvdgozelhkoewayspx";

       public static ITask<ImgGenerationsResponse> GetImgGenerationsAsync([JsonContent] ImgGenerationsRequest request) 
        {
            try
            {
                var api = HttpApi.Create<ISiliconFlowAPI>();
                return api.GetImgGenerationsAsync(request);
            }
            catch (Exception)
            {
                return null;
            }
           
        }
    }


    /// <summary>
    /// 
    /// </summary>
    public interface ISiliconFlowAPI : IHttpApi
    {
        /// <summary>
        /// AI图片生产
        /// </summary>
        /// <returns></returns>
        [HttpPost("https://api.siliconflow.cn/v1/images/generations")]
        [Header("authorization", $"Bearer sk-kwocbgqjoqjhplbzqxhkqtplmnreuzfvdgozelhkoewayspx")]
        [JsonReturn] 
        ITask<ImgGenerationsResponse> GetImgGenerationsAsync([JsonContent] ImgGenerationsRequest data);


        /// <summary>
        /// AI图片生产
        /// </summary>
        /// <returns></returns>
        [HttpPost("https://api.siliconflow.cn/v1/chat/generations")]
        [Header("authorization", $"Bearer sk-kwocbgqjoqjhplbzqxhkqtplmnreuzfvdgozelhkoewayspx")]
        [JsonReturn]
        ITask<string> GetChatAsync([JsonContent] ChatGenerationsRequest data);
    }
}
